/**
 * 
 */
package com.runningfox.logic;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author lhy
 *
 */
public class DateUitl {
	public static final String format = "yyyy-MM-dd hh:MM:ss";
	public static final SimpleDateFormat dateFormat = new SimpleDateFormat(
	"yyyy-MM-dd hh:MM:ss");
	/**
	 * 兼容‘2009-12-17 09:04:38.445318’与’2009-12-17 09:04:38‘两种格式
	 * @param dateStr
	 * @return
	 * @throws ParseException
	 */
	public Date parse(String dateStr) throws ParseException{
		String str = dateStr;
		int dotIndex = dateStr.lastIndexOf('.');
		if(dotIndex>0){
			str = str.substring(0, dotIndex);
		}
		return dateFormat.parse(str);
	}
}
